#include <iostream>
#include <string>
#include "../head/DenseGraph.h"
#include "../head/SparseGraph.h"
#include "../head/ReadGraph.h"
#include "../head/Components.h"
#include "../head/path.h"
#include "../head/ShortestPath.h"


using namespace std;

void testFile(const string name);
void testComponent();
void printPath();

int main(){
	// testFile("testG1.txt");
	// testComponent();
	printPath();
}


// 从文件中读取图,并用稀疏图和稠密图分别遍历打印
void testFile(const string name){
	SparseGraph g1(13, false);
	ReadGraph<SparseGraph> readGraph1(g1, name);
	g1.show();

	cout << endl;

	DenseGraph g2(13, false);
	ReadGraph<DenseGraph> readGraph2(g2, name);
	g2.show();
}


// 测试一张图有几个联通量(分几部分)
void testComponent(){
    // TestG1.txt
    string filename1 = "testG1.txt";
    SparseGraph g1 = SparseGraph(13, false);
    ReadGraph<SparseGraph> readGraph1(g1, filename1);
    Component<SparseGraph> component1(g1);
    cout<<"TestG1.txt, Component Count: "<<component1.count()<<endl;

    cout<<endl;

    // TestG2.txt
    string filename2 = "testG2.txt";
    SparseGraph g2 = SparseGraph(7, false);
    ReadGraph<SparseGraph> readGraph2(g2, filename2);
    Component<SparseGraph> component2(g2);
    cout<<"TestG2.txt, Component Count: "<<component2.count()<<endl;
}

void printPath(){
	string filename = "testG2.txt";
	SparseGraph g = SparseGraph(7, false);
	ReadGraph<SparseGraph> readGraph(g, filename); // 读取到内存中
	g.show();
	cout << endl;

	// 找出从 0 到6节点路径  广度优先遍历
	Path<SparseGraph> dfs(g, 0);	// 调用Path类的构造函数,构造dfs对象
	cout << "DFS : ";
	dfs.showPath(6);

	// 找出0到6节点最短路径 深度优先遍历
	ShortestPath<SparseGraph> bfs(g, 0);
	cout << "BFS : ";
	bfs.showPath(6);
}
